﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Entity
{
    public class ApiDBContextFactory : IDesignTimeDbContextFactory<SMDBContext>
    {
        public  SMDBContext CreateDbContext(string[] args)
        {
            IConfigurationRoot? configuration = new ConfigurationBuilder().Build();

            var builder = new DbContextOptionsBuilder<SMDBContext>();

            builder.UseMysql(configuration?. GetConnectionString("aiydb"), MySqlServerVersion.LatestSupportedServerVersion);

            return new SMDBContext(builder.Options);
         }
    }

}
